<script type="text/javascript">
    layui.config({
        base: "{:C(JS_BASE_PATH)}"
    }).use(['layer','form','func'], function(){
        var layer = layui.layer,
                form = layui.form(),
                func = layui.func,
                $ = layui.jquery;
        /*
        *ajax请求
        **/
        $("[event=edit]").click(function () {
            var key = $(this).parents('tr').attr('key'),
                data = $.dataSource.data[key],
                formTpl = $("[event=formTpl]");
            func.layerOpen('编辑模型',formTpl.html(),'editTpl');
            var $edit = $('#editTpl');
            $edit.find("input[name='name']").val(data.name);
            $edit.find("input[name='description']").val(data.description);
            $edit.find("input[name='sort']").val(data.sort);
            $edit.find("input[name='tablename']").val(data.tablename);
            $edit.find("input[name='id']").val(data.id);
            $edit.find("input[name='status']").filter("[value=" + data.status + "]").click();
            $edit.find('[event=submit]').attr('lay-filter','edit');
            $edit.find('[event=submit]').html('编辑');
            form.render();
        });

        form.on('submit(edit)',function (data) {
            func.ajax("{:U('edit')}",data.field);
            return false;
        });
    });
</script>